package com.hqyj.controller;


import com.hqyj.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.HashMap;


/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author rock
 * @since 2021-10-21
 */
@Controller
@RequestMapping("/user")
public class UserController {

    //访问index页面
    @RequestMapping("/indexPage")
    public String indexPage(){return "index";}

    //获取userName
    @RequestMapping("/userName")
    @ResponseBody
    public HashMap<String,Object> userName(User user,HttpSession session){
        HashMap<String ,Object> map = new HashMap<>();
        User user1 = (User) session.getAttribute("USER");
        map.put("userName",user1.getSysName());
        map.put("password",user1.getSysPwd());
        return map;
    }
    //获取sysId
    @RequestMapping("/sysId")
    @ResponseBody
    public HashMap<String,Object> sysId(User user,HttpSession session){
        HashMap<String ,Object> map = new HashMap<>();
        int sysId = (int) session.getAttribute("sysId");
        String sysEmail = (String) session.getAttribute("sysEmail");
        map.put("sysEmail",sysEmail);
        map.put("sysId",sysId);
        return map;
    }
}

